package com.jia.train.seat.controller;

import com.jia.train.global.page.PageResponse;
import com.jia.train.global.response.BaseResponse;
import com.jia.train.seat.request.DailyTripStationQueryRequest;
import com.jia.train.seat.request.DailyTripStationSaveRequest;
import com.jia.train.seat.response.DailyTripStationQueryResponse;
import com.jia.train.seat.response.DailyTripStationSaveResponse;
import com.jia.train.seat.service.DailyTripStationService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/daily/trip/station")
public class DailyTripStationController {

    @Resource
    private DailyTripStationService dailyTripStationService;

    @PostMapping("/insert")
    public BaseResponse<DailyTripStationSaveResponse> insertDailyTripStation(@Valid @RequestBody DailyTripStationSaveRequest request) {
        DailyTripStationSaveResponse response = dailyTripStationService.insert(request);
        return new BaseResponse<>(response);
    }

    @GetMapping("/query")
    public BaseResponse<PageResponse<DailyTripStationQueryResponse>> query(@Valid DailyTripStationQueryRequest request) {
        PageResponse<DailyTripStationQueryResponse> responseList = dailyTripStationService.selectList(request);
        return new BaseResponse<>(responseList);
    }

    @DeleteMapping("/delete/{id}")
    public BaseResponse<String> delete(@PathVariable Long id) {
        dailyTripStationService.deleteDailyTripStation(id);
        return new BaseResponse<>("success");
    }

}
